package com.woniu.day8.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.day8.mapper.RecordsMapper;
import com.woniu.day8.pojo.Parking;
import com.woniu.day8.pojo.Records;
import com.woniu.day8.pojo.UserInfo;
import com.woniu.day8.service.RecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordsServiceImpl extends ServiceImpl<RecordsMapper, Records> implements RecordsService {
    @Autowired
    private RecordsMapper recordsMapper;
    @Override
    public List<Records> queryRecords(Page<Records> page, Records conditions){
        QueryWrapper<Records> queryWrapper = new QueryWrapper<>();

        // 添加查询条件
        if (conditions.getId() != null) {
            queryWrapper.eq("r.id", conditions.getId());// id查询
        }
        if (conditions.getTypeId() != null) {
            queryWrapper.like("type_id", conditions.getTypeId());//缴费类型查询
        }
        if (conditions.getHouseId() != null) {
            queryWrapper.eq("house_id", conditions.getHouseId());//房屋名字查询
        }
        // 使用自定义的queryUsers方法查询用户及其角色信息
        List<Records> list = recordsMapper.selectRecords(page, queryWrapper);
        return list;
    }
}
